package com.tanjun.common.enums.user;


import com.fasterxml.jackson.annotation.JsonValue;
import com.mybatisflex.annotation.EnumValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

@Getter
@AllArgsConstructor
public enum AdminUserTypeEnum {
    /**
     * 后台管理用户
     */
    SYSTEM(1,"后台系统管理员"),

    /**
     * 商户用户
     */
    VENDOR(2,"商户用户")
    ;
    @JsonValue
    @EnumValue
    private  Integer code;

    private  String name;

    /**
     * 枚举数据库存储值
     */

    public Integer getValue() {
        return code;
    }

    public static AdminUserTypeEnum valueFrom(Integer code){
      return   Arrays.stream(AdminUserTypeEnum.values())
                .filter(t-> Objects.equals(t.getCode(), code))
                .findFirst()
                .orElse(null);
    }
}
